/*
 *
 * @ProjectName:    my_umi_app
 * @Package:
 * @ClassName:      blog_setting_api
 * @Description:    博客相关设置
 * @Author:         SuPeiSen
 * @CreateDate:     2021/2/9 5:44 下午
 * @UpdateDate:     2021/2/9 5:44 下午
 * @UpdateRemark:   更新说明：
 * @Version:        1.0
 */

import { Requests } from '@/utils/requests';
import { BlogSettingType } from '@/type/blog_setting_blog';
import { ApiPath, BlogApiPath } from '@/config/api_config';

/**
 * 获取设置
 * @constructor
 */
export const GetBlogSettingApi = async () => {
  const model = await Requests.defaults.http<BlogSettingType>(
    'get',
    ApiPath.getBlogSetting,
  );
  return model;
};

/**
 * 更新设置
 * @constructor
 */
export const UpdateBlogSettingApi = async (
  param: any,
  finallyCallBack: () => void,
) => {
  const model = await Requests.defaults.http('put', ApiPath.saveBlogSetting, {
    postData: param,
    callBack: {
      finally: finallyCallBack,
    },
  });
  return model.success;
};

/**
 * 更新博主信息
 * @param content
 * @constructor
 */
export const UpdateBloggerInfoApi = async (content: string) => {
  const model = await Requests.defaults.http('put', ApiPath.UpdateBloggerInfo, {
    postData: {
      blogger_content: content,
    },
  });
  return model.success;
};

/**
 * 获取博主简介
 * @param content
 * @constructor
 */
export const GetBloggerInfoApi = async () => {
  return await Requests.defaults.http<{
    blogger_content: string;
  }>('get', BlogApiPath.blogGetBloggerInfo);
};
